package com.bjtraffic.gov.info.manager.dao;

import com.bjtraffic.gov.info.manager.domain.Manager;

import java.io.*;
import java.util.ArrayList;

public class ManagerDao {
    //1.新建一个集合用于存储管理员对象
    private static ArrayList<Manager> manList = new ArrayList<>();

    static{
        managerLoad();
    }

    public ArrayList<Manager> land() {
        //2.将管理员集合返还给调用者
        return manList;
    }

    public static void managerLoad() {
        try {
            BufferedReader br = new BufferedReader(new FileReader("bjtraffic-gov-info-manager\\managers.txt"));
            String line;
            while ((line = br.readLine()) != null) {
                String[] split = line.split(",");
                Manager man = new Manager(split[0], split[1], split[2], split[3]);
                manList.add(man);
            }
            br.close();
        } catch (IOException e) {
        }
    }
}
